﻿#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string.h>
int main() {
	//整形提升
	//有符号整数提升是按照变量的数据类型的符号位来提升的
	//无符号整数提升，⾼位补0
	char a = -1;
	//10000000000000000000000000000001
	//11111111111111111111111111111110
	//11111111111111111111111111111111
	//存储在a中要发生截断
	//11111111 - a
	//整形提升(看符号位，⾼位补充符号位)
	//11111111111111111111111111111111（%d打印是有符号数，补码->源码）
	//10000000000000000000000000000000
	//10000000000000000000000000000001
	signed char b = -1;
	//11111111 - b
	unsigned char c = -1;
	//11111111 - c
	//00000000000000000000000011111111
	printf("a=%d,b=%d,c=%d", a, b, c);
	char d = -128;
	char e = 128;
	//10000000000000000000000010000000
	//11111111111111111111111101111111
	//11111111111111111111111110000000
	//截断
	//10000000 - d
	//整型提升(看符号位，就是最高位)
	//11111111111111111111111110000000（%u打印是无符号数，补码就是原码）
	printf("%u %u\n", d, e);
	char arr[1000];
	//-128到127
	//-1 -2 -3...-128 127 126...4 3 2 1 0 -1 -2...-128 127...
	//128+127=255
	int i;
	for (i = 0; i < 1000; i++) {
		arr[i] = -1 - i;
	}
	printf("%d\n", strlen(arr));//求字符串长度找的是\0,\0的ASCⅡ码值是0，其实找的就是0
	/*unsigned char i = 0;
	for (i = 0; i <= 255; i++){
		{
			printf("hello world\n");//i<=255恒成立，死循环
		}
	}*/
	/*unsigned int i;
	for (i = 9; i >= 0; i--)
	{
		printf("%u\n", i);//i>=0恒成立，死循环
	}*/
	//int a[4] = { 1, 2, 3, 4 };
	//int* ptr1 = (int*)(&a + 1);//从首元素地址变成了首元素加一个数组长度的地址
	//int* ptr2 = (int*)((int)a + 1);//从首元素地址变成了首元素加一个字节长度的地址
	//int* ptr3 = (int*)(a + 1);//从首元素地址变成了首元素加一个整型长度的地址
	//printf("%x,%x,%x", ptr1[-1], *ptr2， * ptr3);
	unsigned char a = 200;
	//00000000 00000000 00000000 11001000
	//11001000(截断)
	unsigned char b = 100;
	//00000000 00000000 00000000 01100100
	//01100100(截断)
	unsigned char c = 0;
	c = a + b;
	//a+b
	//00000000 00000000 00000000 11001000
	//00000000 00000000 00000000 01100100
	//00000000 00000000 00000001 00101100
	//c
	//00000000 00000000 00000000 00101100
	printf(" % d % d", a + b, c);
	return 0;
}
